<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link rel="stylesheet" href="/layui/css/layui.css">
    <script type="text/javascript" src="/layui/layui.all.js"></script>
    <script type="text/javascript" src="/js/jquery-3.5.1.min.js"></script>
</head>
<body>
<br><br><br><br><br>
&nbsp;&nbsp;&nbsp;　　　　　<input type="file" id="pic"><br><br><br>
　　　　　　
<button class="layui-btn layui-btn-normal" onclick="insertPic()">提交</button>

</body>
<script>
    var id = location.href.split("?")[1].split("=")[1];

    function insertPic() {
        var formData = new FormData();
        if ($("#pic")[0].files[0] != null) {
            formData.append("pic", $("#pic")[0].files[0]);
        }
        formData.append("id", id);
        $.ajax({
            url: "/plan/updatepic",
            type: "post",
            data: formData,
            dataType: "json",
            processData: false,
            contentType: false,
            success: function (data) {
                alert("修改成功");
                parent.location.reload(true);
                var index = parent.layer.getFrameIndex(Window.name);
                parent.layer.close(index);
                // location.href="updateaccount.html?id="+data.obj;
            },
            error: function (error) {
                alert("新增失败");
            }
        })
    }
</script>
</html>